/**
 * 添加或者修改页面
 */
var OrderPutInfoDlg = {
    data: {
        putNumber: "",
        putCustomerId: "",
        putCustomerName: "",
        putCustomerNumber: "",
        estimatetime: "",
        warehouseId: "",
        warehouseName: "",
        putType: "",
        origin: "",
        sourceunit: "",
        settlement: "",
        carnumber: "",
        shipmentnumber: "",
        billstate: "",
        notes: "",
        version: "",
        deliverId: "",
        createTime: "",
        updateTime: "",
        submissionTime: "",
        examineTime: "",
        startTime: "",
        completeTime: "",
        createUser: "",
        updateUser: "",
        submissionUser: "",
        examineUser: "",
        startUser: "",
        completeUser: "",
        createName: "",
        updateName: "",
        submissionName: "",
        examineName: "",
        startName: "",
        completeName: ""
    }
};

layui.use(['form', 'admin', 'ax','upload'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var upload = layui.upload; //得到 upload 对象
    var layer = layui.layer;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //选完文件后不自动上传
    $('#test9').click(function () {
		var  index = layer.msg('In file processing... Please wait patiently', {
			  icon: 16,
			  shade: [0.2,'#000'], //0.1透明度的白色背景
			  time: false
		});
    	var formdata = new FormData();
    	formdata.append('file', document.getElementById("test8").files[0]);
    	formdata.append('goodsCustomerId', $("#goodsCustomerId").val());
    	$.ajax({
    		type: 'Post',
    		data:formdata,
    		cache: false,//上传文件无需缓存
    		processData:false, //告诉jQuery不要去处理发送的数据
    		contentType:false,
        	url: Feng.ctxPath + "/basicGoods/importExcelUpate",
    		success: function (data) {
        		layer.close(index);
        		if (data.success){
                    Feng.success("Import successful！");
                	var Indexs = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(Indexs);
        		} else {
        			if (data.message !=null &&data.message!='') {
        				var msg =  layer.open({
    	  					  title: 'Prompt' ,
    	  					  content: data.message,
    	  					  btn: ['Confirm'],
    	  					  yes: function (){
    	  						  	layer.close(msg);
    	  					  }
        				});
					} else {
		                    Feng.error("Import failed！");
					}
        		}
    		},
        	error: function(data){
        		layer.close(index);
                Feng.error("Network exception, please try again later！")
          }
    	});
    });

    //返回按钮
    $("#backupPage").click(function () {
    	var Index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(Index);
    });

    $(".a-upload").on("change","input[type='file']",function(){
        $(".showFileName").html("");
        var filePath=$(this).val();
        if(filePath.indexOf("xls")!=-1 || filePath.indexOf("xlsx")!=-1){
            var arr=filePath.split('\\');
            var fileName=arr[arr.length-1];
            $(".showFileName").html(fileName);
        }else{
            $(".showFileName").html("You have not uploaded the file, or the file type you uploaded is incorrect！");
            return false
        }
    })

});
